import React, { PureComponent } from "react"
import Util from '../../../utils';

export default class Lottery extends PureComponent {
    
    constructor(props){
        super(props)
        this.state = {
            viewPort: {
                width: 0,
                height: 0,
            },
        }
    }

    componentDidMount() {
        console.log(`mounted`);
        setTimeout(()=>{
            console.log('go back');
            this.props.history.go(-1);
        }, 5000);
        this.setState({
            viewPort: Util.viewport()    
        });
    }

    componentWillUnmount() {
        if (this.timer) {
            clearTimeout(this.timer)
        }
    }
    back = () =>{
        this.props.history.go(-1);
    }
    render() {
        const {
            width,
            height,
        } = this.state.viewPort;

        var url=location.href.split('url=')[1];
        return (
            <div>
                {/* <i onClick={this.back} className="btn-back">back</i> */}
                <iframe 
                    src={url} 
                    width={width} 
                    height={height - Util.BOTTOM_NAV_HEIGHT + 20} 
                    style={styles.iframe} 
                    frameborder="0"
                    scrolling="auto"
                />
            </div>
        )
    }
}

const styles = {
    iframe: {
        borderWidth: 0,
    }
}